package com.yidu.king.service.impl;

import com.yidu.king.dao.PersonMapper;
import com.yidu.king.domain.Person;
import com.yidu.king.service.PersonService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>@Description: 人员服务类</p>
 * <p>@Author yidu-liandyao</p>
 * <p>@Date: 2021-01-13</p>
 * <p>@Time: 9:06</p>
 */
@Service
public class PersonServiceImpl implements PersonService {
    @Resource
    PersonMapper personMapper; //使用了Spring的核心原理里面的IOC,使用对象时,不需要new出来

    @Override
    public List<Person> selectAll(Person person) {
        return personMapper.selectAll(person);
    }

    @Override
    public int selectCount(Person person) {
        return personMapper.selectCount(person);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return personMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(Person record) {
        //保存完成,id自动就有
        personMapper.insertSelective(record);
        System.out.println("主人的ID是:"+record.getId());
        return record.getId();
    }

    @Override
    public Person selectByPrimaryKey(Integer id) {
        return personMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Person record) {
        return personMapper.updateByPrimaryKeySelective(record);
    }
}
